using System;
using System.Threading;

namespace jSLCore.Client.Presentation.BaseControl.DialogMessage
{
    public class InfoBox : jMessageBox
    {
#if SILVERLIGHT
        public static void ShowDialog(string message)
        {
            ShowDialog(message, 0, null);
        }
#endif

        public static void ShowDialog(string message,BaseControl parent)
        {
            ShowDialog(message, 0, parent);
        }

        public static void ShowDialog(string message, int time, BaseControl parent)
        {
            new InfoBox(message,time).ShowDialog(parent);
        }

        private readonly int _time;

        public InfoBox(string message) : base(message, jMessageBoxIconType.Info)
        {

        }

        public InfoBox(string message,int time)
            : base(message, jMessageBoxIconType.Info)
        {
            _time = time;
        }

        public override void LoadInitialData()
        {
            if(_time>0)
            {
                DoWork(null,(sender,args) => Thread.Sleep((int) args.Int), (sender,args) => InvokeDataSelected(), _time);
            }
        }
    }
}